package androidx.appcompat.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.view.Window;
import androidx.annotation.CallSuper;
import androidx.annotation.IdRes;
import androidx.annotation.LayoutRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import androidx.fragment.app.FragmentActivity;
import o.ae;
import o.aw;
import o.aw.c;
import o.dd;
import o.fe;
import o.fg;
import o.fk;
import o.fk.e;

public class AppCompatActivity extends FragmentActivity implements ae, e {
    private AppCompatDelegate ˋॱ;
    private int ͺ = 0;
    private Resources ॱˊ;

    public void onCreate(@Nullable Bundle bundle) {
        AppCompatDelegate ˊॱ = ˊॱ();
        ˊॱ.ʼ();
        ˊॱ.ˎ(bundle);
        if (ˊॱ.ᐝ() && this.ͺ != 0) {
            if (VERSION.SDK_INT >= 23) {
                onApplyThemeResource(getTheme(), this.ͺ, false);
            } else {
                setTheme(this.ͺ);
            }
        }
        super.onCreate(bundle);
    }

    public void setTheme(@StyleRes int i) {
        super.setTheme(i);
        this.ͺ = i;
    }

    protected void onPostCreate(@Nullable Bundle bundle) {
        super.onPostCreate(bundle);
        ˊॱ().ॱ(bundle);
    }

    @Nullable
    public ActionBar ᐝ() {
        return ˊॱ().ˏ();
    }

    public MenuInflater getMenuInflater() {
        return ˊॱ().ˋ();
    }

    public void setContentView(@LayoutRes int i) {
        ˊॱ().ˊ(i);
    }

    public void setContentView(View view) {
        ˊॱ().ˏ(view);
    }

    public void setContentView(View view, LayoutParams layoutParams) {
        ˊॱ().ˏ(view, layoutParams);
    }

    public void addContentView(View view, LayoutParams layoutParams) {
        ˊॱ().ˎ(view, layoutParams);
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        ˊॱ().ˏ(configuration);
        if (this.ॱˊ != null) {
            this.ॱˊ.updateConfiguration(configuration, super.getResources().getDisplayMetrics());
        }
    }

    public void onPostResume() {
        super.onPostResume();
        ˊॱ().ˎ();
    }

    public void onStart() {
        super.onStart();
        ˊॱ().ˊ();
    }

    public void onStop() {
        super.onStop();
        ˊॱ().ॱ();
    }

    public <T extends View> T findViewById(@IdRes int i) {
        return ˊॱ().ˋ(i);
    }

    public final boolean onMenuItemSelected(int i, MenuItem menuItem) {
        if (super.onMenuItemSelected(i, menuItem)) {
            return true;
        }
        ActionBar ᐝ = ᐝ();
        if (menuItem.getItemId() != 16908332 || ᐝ == null || (ᐝ.ˎ() & 4) == 0) {
            return false;
        }
        return ʼ();
    }

    public void onDestroy() {
        super.onDestroy();
        ˊॱ().ʻ();
    }

    protected void onTitleChanged(CharSequence charSequence, int i) {
        super.onTitleChanged(charSequence, i);
        ˊॱ().ˎ(charSequence);
    }

    public void ʽ() {
        ˊॱ().ॱॱ();
    }

    public void invalidateOptionsMenu() {
        ˊॱ().ॱॱ();
    }

    @CallSuper
    public void ˋ(@NonNull aw awVar) {
    }

    @CallSuper
    public void ˎ(@NonNull aw awVar) {
    }

    @Nullable
    public aw ˏ(@NonNull c cVar) {
        return null;
    }

    public void ˊ(@NonNull fk fkVar) {
        fkVar.ˊ(this);
    }

    public void ॱ(@NonNull fk fkVar) {
    }

    public boolean ʼ() {
        Intent ॱॱ = ॱॱ();
        if (ॱॱ == null) {
            return false;
        }
        if (ˋ(ॱॱ)) {
            fk ˏ = fk.ˏ((Context) this);
            ˊ(ˏ);
            ॱ(ˏ);
            ˏ.ˋ();
            try {
                fe.ˏ(this);
            } catch (IllegalStateException e) {
                finish();
            }
        } else {
            ˎ(ॱॱ);
        }
        return true;
    }

    @Nullable
    public Intent ॱॱ() {
        return fg.ˋ(this);
    }

    public boolean ˋ(@NonNull Intent intent) {
        return fg.ˋ((Activity) this, intent);
    }

    public void ˎ(@NonNull Intent intent) {
        fg.ॱ(this, intent);
    }

    public void onContentChanged() {
        ͺ();
    }

    @Deprecated
    public void ͺ() {
    }

    public boolean onMenuOpened(int i, Menu menu) {
        return super.onMenuOpened(i, menu);
    }

    public void onPanelClosed(int i, Menu menu) {
        super.onPanelClosed(i, menu);
    }

    public void onSaveInstanceState(Bundle bundle) {
        super.onSaveInstanceState(bundle);
        ˊॱ().ˊ(bundle);
    }

    @NonNull
    public AppCompatDelegate ˊॱ() {
        if (this.ˋॱ == null) {
            this.ˋॱ = AppCompatDelegate.ˋ(this, this);
        }
        return this.ˋॱ;
    }

    public boolean dispatchKeyEvent(KeyEvent keyEvent) {
        int keyCode = keyEvent.getKeyCode();
        ActionBar ᐝ = ᐝ();
        if (keyCode == 82 && ᐝ != null && ᐝ.ˋ(keyEvent)) {
            return true;
        }
        return super.dispatchKeyEvent(keyEvent);
    }

    public Resources getResources() {
        if (this.ॱˊ == null && dd.ˋ()) {
            this.ॱˊ = new dd(this, super.getResources());
        }
        return this.ॱˊ == null ? super.getResources() : this.ॱˊ;
    }

    private boolean ॱ(int i, KeyEvent keyEvent) {
        if (!(VERSION.SDK_INT >= 26 || keyEvent.isCtrlPressed() || KeyEvent.metaStateHasNoModifiers(keyEvent.getMetaState()) || keyEvent.getRepeatCount() != 0 || KeyEvent.isModifierKey(keyEvent.getKeyCode()))) {
            Window window = getWindow();
            if (!(window == null || window.getDecorView() == null || !window.getDecorView().dispatchKeyShortcutEvent(keyEvent))) {
                return true;
            }
        }
        return false;
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (ॱ(i, keyEvent)) {
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    public void openOptionsMenu() {
        ActionBar ᐝ = ᐝ();
        if (!getWindow().hasFeature(0)) {
            return;
        }
        if (ᐝ == null || !ᐝ.ˊ()) {
            super.openOptionsMenu();
        }
    }

    public void closeOptionsMenu() {
        ActionBar ᐝ = ᐝ();
        if (!getWindow().hasFeature(0)) {
            return;
        }
        if (ᐝ == null || !ᐝ.ˋ()) {
            super.closeOptionsMenu();
        }
    }
}
